import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { ApiParam, ApiTags } from '@nestjs/swagger';
import { CommentService } from './comment.service';
import { CommentDto } from './dto/comment.dto';

@Controller('')
@ApiTags('评论')
export class CommentController {
    constructor(private readonly commentService: CommentService){}

    @Post('comment')
    createComment(@Body() newComment: CommentDto){
        return this.commentService.saveComment(newComment)
    }

    @Get('comment/:commentId')
    @ApiParam({
        name: 'commentId',
        description: '请传入评论Id' 
    })
    getCommentInfoById(@Param('commentId') commentId){
        return this.commentService.getCommentById(commentId)
    }

    @Get('comment/blog/:blogId')
    @ApiParam({
        name: 'blogId',
        description: '请传入文章Id' 
    })
    getCommentsByBlogId(@Param('blogId') blogId){
        return this.commentService.getAllCommentsByBlogId(blogId)
    }

    @Get('replyComments/comment/:commentId')
    @ApiParam({
        name: 'commentId',
        description: '请传入评论Id'
    })
    getReplyCommentsByCommentId(@Param('commentId') commentId){
        return this.commentService.getReplyCommentById(commentId)
    }
}
